import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name:'index',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: () => import('../views/admin/article/index')
  },
  {
    path: '/user',
    name: 'user',
    component: () => import('../views/user')
  },
  {path: '/toUser', name: "toUser", redirect: '/user'},
  {path: '/toIndex', name: "toIndex", redirect: '/'},
  {path: '/toLogin', name: "toLogin", redirect: '/login'}
]

const router = createRouter({
  history: createWebHistory("/"),
  //history: createWebHashHistory(),
  routes
})


export default router
